﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common.Logging.Loupe.Example
{
    /// <summary>
    /// Simple class to demonstrate how to use the logging integration
    /// </summary>
    public class LogExample
    {
        /// <summary>
        /// The current logger retrieved from LogManager
        /// </summary>
        private readonly ILog _logger;

        /// <summary>
        /// Initializes a new instance of type LogExample
        /// </summary>
        public LogExample()
        {
            LoupeLogUtility.StartSession("Initializing model");
            _logger = LogManager.GetCurrentClassLogger();
        }

        /// <summary>
        /// Writes the provided message to the Log
        /// </summary>
        /// <param name="level">The level that the message should be written at.</param>
        /// <param name="message">The message to write.</param>
        public void WriteLogMessage(LogLevel level, string message)
        {
            switch (level)
            {
                case LogLevel.Debug:
                    _logger.Debug(message);
                    break;

                case LogLevel.Error:
                    _logger.Error(message);
                    break;

                case LogLevel.Fatal:
                    _logger.Fatal(message);
                    break;

                case LogLevel.Info:
                    _logger.Info(message);
                    break;

                case LogLevel.Trace:
                    _logger.Trace(message);
                    break;

                case LogLevel.Warn:
                    _logger.Warn(message);
                    break;
            }
        }
    }
}
